<template>
	<view>
		<w-list :list='homeList' text='您尚无投诉订单' :status='status'>
			<template>
				<view v-for="(item,index) in homeList" :key="index">
					<w-complaint-list :item='item' :index='index' @delect='delect'></w-complaint-list>
				</view>
			</template>
		</w-list>
		<w-left-bottom-btn @click='clickBtn'></w-left-bottom-btn>
	</view>
</template>

<script>
	import { selectAdvice,deleteAdvice } from '@/api/index.js'
	export default {
		data() {
			return {
				homeList:[],
				query:{
					pageNo:1,
					pageSize:10
				},
				status:'loadmore'
			}
		},
		onShow() {
			this.query.pageNo = 1
			this.homeList = []
			this.selectAdvice()
		},
		onPullDownRefresh() {
			this.query.pageNo = 1
			this.homeList = []
			this.selectAdvice()
		},
		onReachBottom() {
			this.query.pageNo ++
			this.selectAdvice()
		},
		methods: {
			delect(id,idx){
				deleteAdvice({id}).then(res=>{
					this.homeList.splice(idx,1)
					this.$u.toast('删除成功')
				})
			},
			selectAdvice(){
				this.query.ownerId = uni.getStorageSync('ownerId')
				selectAdvice(this.query).then(res=>{
					const arr = res.list
					if(arr.length==10){
						this.status = 'loadmore'
					}else{
						this.status = 'nomore'
					}
					this.homeList = this.homeList.concat(arr)
				})
			},
			clickBtn(){
				this.$u.route('/pages/index/complaint/complaint')
			}
		}
	}
</script>

<style>

</style>
